#!/usr/bin/env bash
projectName=dola

be_runtime=/runtime/$projectName/service/be

if [ ! -d $be_runtime ]; then
    mkdir -p $be_runtime
fi


#资源路径
resource_home=$be_runtime/resource

if [ ! -d $resource_home ];then
    mkdir -p $resource_home
fi


log4j_home=/opt/log4j
if [ ! -d $log4j_home ];then
    mkdir -p $log4j_home
fi


be_home=/opt/$projectName/
cd $be_home


fanglangHostname=`hostname`
#这是测试服务器
if [ $fanglangHostname = "chenj-mongo" ]; then
#    配置成测试环境
    sed -i 's/^server.port=.*/server.port=9999/g' src/main/resources/application.properties
else
    sed  -i 's/^server.port=.*/server.port=80/g'  $be_home/src/main/resources/application.properties
fi

sed -i 's/^spring.servlet.multipart.location=.*/spring.servlet.multipart.location=\/opt\/tmp/g'  $be_home/src/main/resources/application.properties


cp  -rf $be_home/src/main/resources/* $resource_home


#编译
cd $be_home
mvn clean package spring-boot:repackage -Dmaven.test.skip


if [ ! -d /runtime/dola/service/public/.well-known/ ]; then
  mkdir -p /runtime/dola/service/public/.well-known/
fi

#复制stripe文件
cp -f $be_home/src/main/resources/apple-developer-merchantid-domain-association /runtime/dola/service/public/.well-known/

#拷贝资源
cd $be_home/target



cp $projectName-0.0.1-SNAPSHOT.jar $be_runtime